import 'package:flutter_common_utils/common_utils_export.dart';
import 'package:url_launcher/url_launcher.dart';

class JumpOtherAppUtils {
  JumpOtherAppUtils._();

  /// 跳转其他App
  static Future<bool> jumpApp(String? url) async {
    if (url.isNullOrEmpty()) return false;
    final Uri uri = Uri.parse(url ?? '');
    if (await canLaunchUrl(uri)) {
      return launchUrl(uri);
    } else {
      return false;
      // JhProgressHUD.showText(message);
    }
  }

  /// 跳转其他App
  static Future<bool> jumpAppX(String? appUrl, String? webUrl) async {
    if (!(await jumpApp(appUrl))) {
      return jumpApp(webUrl);
    }
    return true;
  }

  static Future<bool> callPhone(String contactNumber) {
    return jumpApp("tel:$contactNumber");
  }
}

enum MapAppType {
  google,
  baidu,
  amap,
  apple,
}
